package piano;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Synthesizer;

public class ChromaticSynth implements Runnable{
    //vars
    private Synthesizer synth;
    private MidiChannel mchannel;
    private int playNote;
    private Thread myThread;

    //constructor
    public ChromaticSynth(int playNote){
        try {
            synth=MidiSystem.getSynthesizer();
            synth.open();
            mchannel=synth.getChannels()[0];
            this.playNote=playNote;

        } catch (MidiUnavailableException ex) {
            Logger.getLogger(ChromaticSynth.class.getName()).log(Level.SEVERE, null, ex);
        }


     }

    //play sound
    public void run(){
    	System.out.println("Play");
        mchannel.noteOn(playNote,1000);
    }
}